# -*- coding: utf-8 -*-
import scrapy
import json

class DoubanSpider(scrapy.Spider):
    name = 'douban'

    #start_urls = ['https://movie.douban.com/j/search_subjects?type=movie&tag=%E7%83%AD%E9%97%A8&sort=recommend&page_limit=20&page_start=20']
    start_urls = ['https://movie.douban.com/subject/26279175/?tag=%E7%83%AD%E9%97%A8&from=gaia']


    def parse(self, response):
        self.log('----------------')
        
        for href in response.xpath('//*[@id="content"]/div/div[1]/div/div[4]/div/a'):
            full_url = href.extract()
            self.log('aaa'+full_url)
            # yield scrapy.Request(full_url, callback=self.parseSegFault)




    def parse_bak(self, response):
        self.log('----------------')
        subjects = json.loads(response.text)['subjects']
        # self.log( subjects )
    
        for item in subjects:
            self.log(type(item))
            # self.log(item)
            # full_url = href.extract()
            # yield scrapy.Request(item, callback=self.parse_douban)
            # self.log(href.extract())
        # return {'url': 'ok'}



    

    def parse_douban(self, response):
        yield {
            'title': response.xpath('//*[@id="content"]/h1/span[1]').extract(),
            'url': response.url,
        
        }






